package com.wicket.okrapp.biz.service.nb;
 import cn.hutool.core.bean.BeanUtil;
 import com.wicket.okrapp.biz.service.dto.common.TargetTempDto;
 import com.wicket.okrapp.common.baseinfo.BaseInfoDO;
 import com.wicket.okrapp.common.baseinfo.BaseInfoHolder;
 import com.wicket.okrapp.common.util.CommonFunctionHelper;
 import org.springframework.stereotype.Service;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import com.wicket.okrapp.biz.service.dto.req.UnrepeatedTargetObjReqDto;
import com.wicket.okrapp.biz.service.dto.res.UnrepeatedTargetObjRespDto;

 import java.util.ArrayList;
 import java.util.List;
import com.wicket.okrapp.biz.service.dto.req.ImplementAcceptTargetTempFieldsReqDto;
import com.wicket.okrapp.biz.service.dto.res.ImplementAcceptTargetTempFieldsRespDto;
import com.wicket.okrapp.biz.service.dto.req.ImplementBizPublicFieldPushMemoryReqDto;
import com.wicket.okrapp.biz.service.dto.res.ImplementBizPublicFieldPushMemoryRespDto;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbTargetTemp {
/**
      * code:collectionRemoveExistingData
      * name:M3去重指标（特殊方法）
      * desc:undefined
      * gen by moon at 9/19/2022, 6:48:02 PM
      * 
      **/
     @Trace(operationName = "M3去重指标（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public UnrepeatedTargetObjRespDto unrepeatedTargetObj(UnrepeatedTargetObjReqDto reqDto) {
         UnrepeatedTargetObjRespDto retData = new UnrepeatedTargetObjRespDto();
         List<TargetTempDto> filteredList = new ArrayList<>();
         for(TargetTempDto one : reqDto.getTargetTempList()){
             if(!reqDto.getTargetObjList().contains(one.getObjectiveTemplateId())){
                 filteredList.add(one);
             }
         }
         retData.setTargetTempList(filteredList);
        return retData;
      }
/**
      * code:receptionService
      * name:M3指标模板类型（定量）
      * desc:undefined
      * gen by moon at 12/9/2022, 1:46:25 PM
      *
      **/
     @Trace(operationName = "M3指标模板类型（定量）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementAcceptTargetTempFieldsRespDto implementAcceptTargetTempFields(ImplementAcceptTargetTempFieldsReqDto reqDto) {
        return BeanUtil.toBean(reqDto,ImplementAcceptTargetTempFieldsRespDto.class);
      }
/**
      * code:publicFieldCache
      * name:M3业务应用公共字段推送内存
      * desc:undefined
      * gen by moon at 5/29/2023, 9:56:14 PM
      *
      **/
     @Trace(operationName = "M3业务应用公共字段推送内存")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementBizPublicFieldPushMemoryRespDto implementBizPublicFieldPushMemory(ImplementBizPublicFieldPushMemoryReqDto reqDto) {
         BaseInfoDO domain = new BaseInfoDO();
         if(BaseInfoHolder.contextHolder.get()!=null){
             BeanUtil.copyProperties(BaseInfoHolder.contextHolder.get().getBaseInfo(),domain);
             BaseInfoHolder.contextHolder.remove();
         }
         if(reqDto.getSpaceId()!=null){
             domain.setSpecSpaceId(reqDto.getSpaceId());
         }

         if(reqDto.getCreateInductionId()!=null){
             domain.setSpecInductionRecordId(reqDto.getCreateInductionId());
         }

         if(reqDto.getAppId()!=null){
             domain.setSpecAppId(reqDto.getAppId());
         }

         CommonFunctionHelper.setBaseInfoToLocal(domain);
         return new ImplementBizPublicFieldPushMemoryRespDto();
      }
    //手工接入方法
}
